链表中倒数第K个节点 Posted on 2019-08-14 | In 剑指offer | | reads times 链表中倒数第K个节点题目描述 输入一个链表,输出该链表中倒数第k个结点。 12345678910111213141516171819function FindKthToTail(head, k){ // write code here if(head===null||k<0) return null; var node1=head; var node2=head; while(--k){ if(node1.next===null){ return null; }else{ node1=node1.next; } } while(node1.next!==null){ node1=node1.next; node2=node2.next; } return node2;} Post author: GoldMiner Xun Post link: https://goldminerxun.github.io/2019/08/14/%E5%89%91%E6%8C%87offer%20JavaScript%E7%89%88%20(14)/ Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 3.0 unless stating additionally.